<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录界面</title>
    <link rel="stylesheet" href="../static/css/xadmin.css">
    <link rel="stylesheet" href="../static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="../static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../static/js/xadmin.js"></script>
    <script src="../static/js/my.js"></script>
	
	
	
</head>
<body background="../../../../target/classes/static/images/3.jpg">

<div class="login">
    <div class="message layui-bg-orange">用户登录</div>
    <div id="darkbannerwrap"></div>

    <form method="post" id="userForm" class="layui-form">
        <input name="userName" placeholder="请输入用户名"  type="text" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        <input name="userPwd" placeholder="请输入密码"  type="password" lay-verify="required"  class="layui-input">
        <hr class="hr15">
        <input name="email" id="email" placeholder="请输入邮箱账号::"  type="text" lay-verify="email" class="layui-input" >
        <hr class="hr15">
		
        <input name="VerifyCode" placeholder="请输入验证码："  type="text"  class="layui-input">
        <hr class="hr15">
        <button class="layui-btn layui-btn-radius layui-btn-warm" type="submit" lay-submit lay-filter="sendCode">发送验证码</button>
        <button class="layui-btn layui-btn-radius layui-btn-warm" type="submit" lay-submit lay-filter="login">登录</button>
        <a href="zhuce.html" class="layui-btn layui-btn-radius layui-btn-warm"> 注册页面</a>
		
        <span id="e" style="color: red"></span>
    </form>
</div>
<!---->
</body>
</html>
<script>

    //发送验证码
    $(function () {
        layui.use('form',function () {
            var  form = layui.form;
            //发送验证码
            form.on('submit(sendCode)',function (data) {
                console.log("点击发送验证码")
                $.ajax({
                    url:address+"/Sanyecao_Login/sendEmail",
                    type:"post",
                    data:data.field,
                    dataType:"json",//返回的数据类型
                    success:function(d){
                        //定义{info:"success"}
                        $("#e").text(d.info);
                    }
                })
                return false;//不让代码往下运行
            });
            //登录验证
            form.on('submit(login)',function (data) {
                console.log(data.field);
                //先验证验证码是不是空的
                if(data.field.VerifyCode==""){
                    layer.alert("邮箱验证码不能为空");
                    console.log("验证码是空的");
                }
                $.ajax({
                    url:address+"/Sanyecao_Login/VerifyLogin",
                    type:"post",
                    data:data.field,
                    dataType:"json",//返回的数据类型
                    success:function (d) {
                        if(d.info=="登录验证成功"){
                            //跳转到主界面
                            window.location.href="index.html";
                        }else {
                          
                        }
                    }
                })
                return false;//不让代码往下运行
            })
        });

    })

</script>